<?php
/**
 * desc Created by wang.
 * User: wang
 * motto: 是时候为小时候吹过的牛而努力了!
 * Date: 2020/3/23 16:10
 */

namespace app\admin\validate;


use think\Validate;

class Login extends Validate
{
    protected $rule = [
        'username' => 'require',
        'password' => 'require|length:6,16|regex:^(?=.*[a-zA-Z])(?=.*?[0-9])[\s\S]*$',
        'password1' => 'require|length:6,16|regex:^(?=.*[a-zA-Z])(?=.*?[0-9])[\s\S]*$',
        'password2' => 'require|length:6,16|regex:^(?=.*[a-zA-Z])(?=.*?[0-9])[\s\S]*$',
    ];

    protected $message = [
        'username.require' => '账号不能为空',
        'password.require' => '密码不能为空',
        'password.length' => '密码长度为6-16',
        'password.regex' => '密码必须同时包含字母和数字',
        'password1.require' => '密码不能为空',
        'password1.length' => '密码长度为6-16',
        'password1.regex' => '密码必须同时包含字母和数字',
        'password2.require' => '密码不能为空',
        'password2.length' => '密码长度为6-16',
        'password2.regex' => '密码必须同时包含字母和数字',
    ];

    //需要校验的场景
    protected $scene = [
        'login' => ['username', 'password'],
        'edit' => ['password', 'password1', 'password2'],
    ];
}